﻿using Ndns.Listener;
using Ndns.ServerHost.Abstractions;
using System;
using System.Net;

namespace Ndns.ServerHost.Builder
{
    public static class DnsListenerMiddlewareBuilder
    {

        public static IMiddlewaresBuilder UseListener(this IMiddlewaresBuilder builder, DnsProtocol protocol, IPEndPoint ipEndPoint)
        {
            if (builder == null)
                throw new ArgumentNullException(nameof(builder));
            if (ipEndPoint == null)
                throw new ArgumentNullException(nameof(ipEndPoint));

            builder.Use(new DnsListenerMiddleware(protocol, ipEndPoint));

            return builder;
        }
    }
}
